package com.wechat.backend.controller;

import com.wechat.backend.entity.Message;
import com.wechat.backend.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @GetMapping("/history")
    public List<Message> getHistory(@RequestParam Integer userId, @RequestParam Integer friendId) {
        return messageService.getHistory(userId, friendId);
    }

    @GetMapping("/unread-count")
    public Map<String, Object> getUnreadCount(@RequestParam Integer userId, @RequestParam Integer friendId) {
        return messageService.getUnreadCount(userId, friendId);
    }

    @PostMapping("/read-all")
    public Map<String, Object> markAllAsRead(@RequestParam Integer userId, @RequestParam Integer friendId) {
        return messageService.markAllAsRead(userId, friendId);
    }
} 